package plate

import "time"

//获取所有非空的值
func (logic *Logic_t) getAllwhitNoEmpty() []CarResult_t {
	res := make([]CarResult_t, 0)

	l := logic.Queue
	if l == nil {
		return res
	}
	for e := l.Front(); e != nil; e = e.Next() {
		r, ok := e.Value.(CarResult_t)
		if ok {
			res = append(res, r)
		}
	}
	return res
}

func (logic *Logic_t) getCarResult(time_now time.Time) {

	back := logic.Now_CarResult

	carResults := logic.getAllwhitNoEmpty()
	whether := judgeWhetherCar(logic.Now_CarResult, carResults)

	carResults_len := len(carResults)
	if carResults_len != 0 {
		logic.Now_CarResult.Car.LocalName = carResults[carResults_len-1].Car.LocalName
		logic.Now_CarResult.Car.LogicNum = carResults[carResults_len-1].Car.LogicNum
	}

	if whether == 2 {
		logic.Now_CarResult.IsEmpty = true
	} else if whether == 1 {
		logic.Now_CarResult.Car.CarType, logic.Now_CarResult.Car.PlateNO, logic.Now_CarResult.Car.PlateColor = judgeGetCarResult(logic.Now_CarResult, carResults, whether)
	} else {
		logic.Now_CarResult.Car.CarType = ""
		logic.Now_CarResult.Car.PlateNO = ""
		logic.Now_CarResult.Car.PlateColor = ""
	}
	logic.Now_CarResult = carResultMakeUp(logic.Now_CarResult)

	if back != logic.Now_CarResult {
		//更新显示值
		logic.Now_CarResult.AppearTime = time_now
	}
}
